package net.awpspace.mobile.management.point;

import java.util.Vector;

import javax.microedition.midlet.MIDlet;

import net.awpspace.mobile.form.BaseForm;

import com.sun.lwuit.List;
import com.sun.lwuit.animations.CommonTransitions;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;

public class XemDiem extends BaseForm {

	private List list;
	private Vector data;

	public XemDiem(MIDlet app, BaseForm parent) {
		super(app, parent);
		setTitle("Member View");
		setTransitionInAnimator(CommonTransitions.createSlide(
				CommonTransitions.SLIDE_HORIZONTAL, true, 1200));
		setTransitionOutAnimator(CommonTransitions.createSlide(
				CommonTransitions.SLIDE_HORIZONTAL, true, 1200));

		data = Data.getInstance().getData();
		list = new List();
		list.setSmoothScrolling(true);
		list.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				itemStateChanged();
			}
		});		
		createComponent();

	}

	protected void itemStateChanged() {
		int index = list.getSelectedIndex();
		new ChiTiet(app, this, (Diem) (data.elementAt(index))).show();
	}

	public void createComponent() {
		for (int i = 0; i < data.size(); i++) {
			if (!((Diem) data.elementAt(i)).getTen().equals(null))
				list.addItem(((Diem) data.elementAt(i)).getTen());
		}
		addComponent(list);
	}

	protected void processCommand(ActionEvent e) {

	}

}
